<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="ui" uri="http://com.am.tag" %>
<%@ include file="../common.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>My JSP 'userList.jsp' starting page</title>
	<script type="text/javascript">
		$().ready(function(){
			$("#startDate").bind("focus",function(){
				
				WdatePicker({"dateFmt":"yyyy"});
			});
			
			$("#endDate").bind("focus",function(){
				
				WdatePicker({"dateFmt":"yyyy"});
			});
		});
		
		function doCheck()
		{
			if($("#startDate").val() == "")
			{
				alert("请选择起始日期");
				return false;
			}
			if($("#endDate").val() == "")
			{
				alert("请选择结束日期");
				return false;
			}
			
			if($("#startDate").val().localeCompare($("#endDate").val()) > 0)
			{
				alert("起始日期不能大于结束日期");
				return false;
			}
			
			return true;
		}
		
		function doBuildChart()
		{
			if(doCheck())
			{
				var map = Form.formToBean("winform");
				map.method = "com.system.dao.ChartDao:getPatientRecordChart";
				map.titleText = "看病记录统计";
				map.yAxisText = "数量";
				map.lineToolTip = "人";
				map.type = "column";
				openDailog("view","${path}/jsp/chart/chart.jsp",800,500,"查看图表",false,true,map);
			}
		}
		
		function doBuildReport()
		{
			if(doCheck())
			{
				var startDate = $("#startDate").val();
				var endDate = $("#endDate").val();
				var dateType = $("input[name='dateType']:checked").val();
				$("#chartFrame").attr("src","${path}/jsp/chart/patientRecordReport.jsp?startDate=" + startDate + "&endDate=" + endDate + "&dateType=" + dateType);
			}
		}
		
		
		function changeDateType(obj)
		{
			var t = obj.value;
			var option = {};
			if(t == "year")
			{
				option.dateFmt = 'yyyy';
			}else if(t == "month")
			{
				option.dateFmt = 'yyyy-MM';
			}else{
				option.dateFmt = 'yyyy-MM-dd';
			}
			$("#startDate").unbind('focus');  
			$("#endDate").unbind('focus');  
			$("#startDate").val("");
			$("#endDate").val("");
			
			$("#startDate").bind("focus",function(){
				
				WdatePicker(option);
			});
			
			$("#endDate").bind("focus",function(){
				
				WdatePicker(option);
			});
			
		}
		
		function doExport()
		{
			window.frames['chartFrame'].doExport();
		}
	</script>
  </head>
  
  <body style="overflow: hidden;">
  	<form id="winForm">
  	<table cellSpacing="0" cellPadding="0" style="width:100%;height:100%;" border="0">
  		<tr>
			<td class="windowTitle">数据统计  &gt; 看病数量统计</td>
		</tr>
  		<tr id="">
  			<td style="height:35px;width:100%" class="windowHead">	
				  	<input name="dateType" type="radio" value="year" onclick="changeDateType(this)" checked>年&nbsp;&nbsp;&nbsp;
				  	<input name="dateType" type="radio" value="month" onclick="changeDateType(this)">月&nbsp;&nbsp;&nbsp;
				  	<input name="dateType" type="radio" value="day" onclick="changeDateType(this)">日&nbsp;&nbsp;&nbsp;
				  	<input name="startDate" class="Wdate" id="startDate" style="width: 160px;" type="text" size="20"/>&gt;&gt;
				  	<input name="endDate" class="Wdate" id="endDate" style="width: 160px;" type="text" size="20"/>
				  	<ui:Button onclick="doBuildReport()"><img src="${path}/images/statistics.png">&nbsp;统计</ui:Button>
				  	<ui:Button id="export" type="export" onclick="doExport()">导出</ui:Button>
					<ui:Button onclick="doBuildChart()"><img src="${path}/images/pie_chart.png">&nbsp;查看图表</ui:Button>
					<a style="text-decoration: none;"></a>
				
			</td>
		</tr>
		
		<tr>
			<td style="width:100%;height:100%;overflow:hidden"  class="windowBody">
				<iframe id="chartFrame" frameborder="0" width="100%" height="100%"></iframe>
		    </td>
		</tr>
  	</table>
  	</form>
  </body>
</html>
